#!/usr/bin/env perl

use strict;
use warnings;

use Template;

my $tt = Template->new;

my %uchar = ( buffer => 'uint8', type => 'Uint8Array', getter => 'UChar', reader => 'UInt8' );
my %ushort = ( buffer => 'uint16', type => 'Uint16Array', getter => 'UShort', reader => 'UInt16' );
my %uint = ( buffer => 'uint32', type => 'Uint32Array', getter => 'UInt', reader => 'UInt32' );
my %char = ( buffer => 'int8', type => 'Int8Array', getter => 'Char', reader => 'Int8' );
my %short = ( buffer => 'int16', type => 'Int16Array', getter => 'Short', reader => 'Int16' );
my %int = ( buffer => 'int32', type => 'Int32Array', getter => 'Int', reader => 'Int32' );
my %float = ( buffer => 'float32', type => 'Float32Array', getter => 'Float', reader => 'Float' );
# my %double = ( buffer => 'float64', type => 'Float64Array', getter => 'Double', reader => 'Double' );

my @type = ({size => 1, names => [\%uchar, \%char]},
	    {size => 2, names => [\%ushort, \%short]},
	    {size => 4, names => [\%uint, \%int, \%float]});

my %data = ( sizes => \@type,
	     buffer_class => 'BinaryBuffer',
	     reader_class => 'BinaryReader');

$tt->process('gen/binary-reader.tt', \%data, 'src/binary-reader.js')
    || die $tt->error;
